package com.jlcindia;

public class Lab18 {

	public static void main(String[] args) {
		System.out.println(Person1.minagetovote);
		Person1 per=null;
		/*per=new Person1();
		per.showworkinfo();*/
		//System.out.println(per.name);
		per=new Employee1("Ravi",7795484339l);
		per.showworkinfo();
		System.out.println(per.name+"\t"+per.phone);
		per=new Oldstudent();
		per.showworkinfo();
		per=new Currentstudent();
		per.showworkinfo();
		System.out.println("==================");
		Person1 p=null;
		p=Personservice.getinstance("Employee1");
		System.out.println(p.getpersontype());
		p=Personservice.getinstance("Oldstudent");
		System.out.println(p.getpersontype());
		p=Personservice.getinstance("Currentstudent");
		System.out.println(p.getpersontype());

	}

}
abstract class Person1{
	static int minagetovote=18;
	String name;
	long phone;
	public Person1(String name, long phone) {
		this.name = name;
		this.phone = phone;
		System.out.println("==person(string,long)==");
	}
	Person1(){
		System.out.println("==person def cons==:"+this);
	}
	{
		System.out.println("\n Instance block of person");
	}
	abstract void showworkinfo();
	abstract String getpersontype();
	void show(){
		//Person1 p=new Person1();
		//p.showworkinfo();
	}
}
//class Farmer extends Person1{}
class Employee1 extends Person1{

	public Employee1() {}
	public Employee1(String name, long phone) {
		super(name, phone);
	}
	String getpersontype(){
	return "Employee1";
	}
	void showworkinfo(){
		System.out.println("==Employee working in company==");
	}
}
abstract class Student2 extends Person1{
	Student2(){ //is by default implemented
		super();
	}
}
class Currentstudent extends Student2{

	void showworkinfo() {
	System.out.println("**Attending the classes**");	
	}
	String getpersontype() {
		return "Currentstudent";
	}
}
class Oldstudent extends Student2{
	
	Oldstudent(){ //is by default implemented
		super();
	}
	void showworkinfo() {
	System.out.println("**Searching for job**");	
	}
	String getpersontype() {
		return "Oldstudent";
	}
}
class Personservice{
	static Person1 getinstance(String cName){
		if(cName.equals("Employee1"))
			return new Employee1();
		else if(cName.equals("Oldstudent"))
			return new Oldstudent();
		else if(cName.equals("Currentstudent"))
			return new Currentstudent();
		else
			return null;
	}
}
